package com.laijiale.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.io.Serializable;
import com.laijiale.constant.RE;

import static com.laijiale.constant.RE.MENU_URL_RE;
import static com.laijiale.constant.RE.MENU_URL_RE_MSG;

/**
 * @author laijiale
 * @date 2025年01月08日 21:44
 */


@Schema(name ="菜单添加DTo")
@Data
public class MenuInsertDTO implements Serializable {

    @NotEmpty(message = "标题不能为空")
    @Size(min = 1, max = 42, message = "标题长度必须在1~42之间")
    @Schema(description = "标题")
    private String title;
    @Size(min = 1, max = 170, message = "描述长度必须在1~170之间")
    @Schema(description = "描述")
    private String info;
    @Pattern(regexp = MENU_URL_RE, message = MENU_URL_RE_MSG)
    @Size(min = 1, max = 256, message = "跳转地址长度必须在1~256之间")
    @Schema(description = "跳转地址")
    private String url;
    @NotEmpty(message = "图标不能为空")
    @Pattern(regexp = "^[a-zA-Z0-9]+$", message = "图标不支持中文")
    @Size(min = 1, max = 256, message = "图标长度必须在1~256之间")
    @Schema(description = "图标")
    private String icon;
    @Range(min = 0, message = "父菜单主键最小为o")
    @Schema(description = "父菜单主键,视为根节点")
    private Long pid;
    @Range(min = 0, message = "序号最小为o")
    @Schema(description = "序号")
    private Long idx;
}
